<template>
	<view class="content">
		<view class="content_list">
			<view class="name">用户ID</view>
			<view class="right">
				<view class="id">{{userId}}</view>
			</view>
		</view>
		<view class="content_list"  @click="infoShow=true">
			<view class="name">是否隐藏个人信息</view>
			<view class="right">
				<view class="text overflow1">{{Info[isInfo]}}</view>
				<uv-icon name="arrow-right" color="#7f8289" size="22"></uv-icon>
			</view>
		</view>
		<view class="content_button" @click="tuichu">退出登录</view>
		<view class="content_set" v-if="infoShow">
			<view class="content_set_bj" @click="infoShow=false"></view>
			<view class="content_set_box">
				<view class="list" @click="setInfo(k)" v-for="(v,k) in Info" :key="k"><text>{{v}}</text><image v-if="k==isInfo" src="../static/image/xuanze.png"></image></view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	import {
		homeApi
	} from "@/api/index"
	const infoShow = ref(false)
	const Info = ref(['公开电话、微信号、邮箱','隐藏电话、微信号、邮箱'])
	const userId = ref('')
	const isInfo = ref(0)
	const setInfo = async(i)=>{
		isInfo.value = i
		infoShow.value = false
		let data = {
			txlhideconcat:isInfo.value
		}
		let res = await homeApi.publicPost(data,'txlsettxlhideconcat')
		for (let i = 0; i < res.columns.length; i++) {
			if (res.columns[i].name == 'txlsettxlhideconcat') {
				if(res.columns[i].statuscode!='200'){
					uni.showToast({
						title: res.columns[i].message,
						icon: 'none',
						duration: 2000
					});
				}
			}
		}
	}
	
	onLoad(()=>{
		getUser()
	})
	const getUser = async()=>{
		let data = {
			do:'userinfo',
		}
		let res = await homeApi.publicGet(data)
		for (let i = 0; i < res.columns.length; i++) {
			if (res.columns[i].name == 'userinfo') {
				console.log(res.columns[i])
				isInfo.value = res.columns[i].txlhideconcat?res.columns[i].txlhideconcat:''
				userId.value = res.columns[i].id?res.columns[i].id:''
			}
		}
	}
	const tuichu = ()=>{
		uni.showModal({
			content: '是否退出？',
			success: (e) => {
				if (e.confirm) {
					uni.clearStorage({
					    success: function () {
							uni.redirectTo({
								url:"/user/login/login"
							})
						}
					})
				}
			}
		})
	}
</script>


<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100%;
		background: #f5f6fa;
		overflow-y: auto;
		&_list {
			width: calc(100% - 60rpx);
			background: #fff;
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1rpx solid #ebecf4;

			.name {
				font-size: 32rpx;
			}

			.right {
				display: flex;
				align-items: center;

				.id {
					font-size: 32rpx;
					font-weight: bold;
				}

				.text {
					font-size: 28rpx;
					color: #999;
					width: 250rpx;
					margin-right: 10rpx;
				}
			}
		}

		&_button {
			width: 100%;
			padding-top: 30rpx;
			padding-bottom: 30rpx;
			margin-top: 50rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32rpx;
			color: #f00;
			background: #fff;
		}

		&_set {
			width: 100%;
			height: 100%;
			position: fixed;
			left: 0;
			top: 0;
			display: flex;
			align-items: center;
			justify-content: center;

			&_bj {
				width: 100%;
				height: 100%;
				background: rgba(0, 0, 0, .2);
				position: absolute;
				left: 0;
				top: 0;
			}

			&_box {
				width: 90%;
				background: #fff;
				border-radius: 15px;
				position: absolute;
				.list{
					display: flex;
					padding: 30rpx;
					width: calc(100% - 60rpx);
					justify-content: space-between;
					border-bottom: 1px solid #ebecf4;
					height: 50rpx;
					image{
						width: 50rpx;
						height: 50rpx;
					}
				}
				.list:nth-last-child(1){
					border-bottom: none;
				}
			}
		}
	}
</style>